In [ ]:
#Have you ever thought about going camping but been worried you might run dry?
#Never fear, for I have solved this problem
#What follows is me finding all the DOC camp sites within an hours drive of a liquor store
In [1]:
#Here are all the imports
#Allows using leaflet.js
import folium
#allows for importing the shapefile
import geopandas as gpd
import os
In [2]:
#Lets make the base map
#m = folium.Map(location=[-41.2769, 174.7731] ,tiles='stamenwatercolor', zoom_start=5)
m = folium.Map(location=[-41.2769, 174.7731],zoom_start=5)
In [3]:
#And lets see it

m
Out[3]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [4]:
#Now lets add all the DOC Campsites
#Using the Qgis QuickOSM plugin its easy to find all the campsites, 
#then filter to just the ones with the "operator" = "Department of Conservation" Attribute
Doc_Camp = gpd.read_file( "Doc_geo_wgs84.geojson")

#And add it to the map

folium.GeoJson(Doc_Camp,name='Doc_Camps').add_to(m)


#Lets see if that worked

m
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [5]:
#Thats all well and good, but the markers are uninteractive right now
#we can use the data to add markers at each point, and have those markers popup the names of the campsites
#Becasue Geopandas loaded the shapefile as a Dataframe, this is reasonably easy

#Lets create a new map
marker_map = folium.Map(location=[-41.2769, 174.7731],zoom_start=5)

#And now a function to get all the data out of the file and plot it
for row in Doc_Camp.iterrows():
    row_values = row[1]
    lat = row_values['geometry'].y
    long = row_values['geometry'].x
    name = row_values['name']
    folium.Marker([lat, long], popup= name).add_to(marker_map)


    
marker_map

#Try Clicking one one :)
Out[5]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [6]:
#Now lets see how far you can get in an hours car ride from all of these
Camp_iso = gpd.read_file( "Dissolved_iso.geojson")

#And add it to the map

folium.GeoJson(Camp_iso,name='Camp_iso').add_to(marker_map)

marker_map

#As you can see some of the more remote campsites have ways fro cars to get in or out, so they have no isochron
Out[6]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [7]:
#Now lets see every liquor store in the country

Liquor_Stores = gpd.read_file( "liquor_geojson_84.geojson")

#And add it to a map

liquor_map = folium.Map(location=[-41.2769, 174.7731],zoom_start=5)

for row in Liquor_Stores.iterrows():
    row_values = row[1]
    lat = row_values['geometry'].y
    long = row_values['geometry'].x
    name = row_values['name']
    folium.Marker(location=[lat,long], icon=folium.Icon(color='red',icon="usd")).add_to(liquor_map)



liquor_map
#Boy we drink a lot
Out[7]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [8]:
#In Qgis I was able to select only the isochrons that have liquor stores in them



iso_containing_liquor = gpd.read_file( "iso_contain_liqour.geojson")

iso_liquor_map = folium.Map(location=[-41.2769, 174.7731],zoom_start=5)

folium.GeoJson(iso_containing_liquor,name='iso_liquor').add_to(iso_liquor_map)


iso_liquor_map
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [9]:
#And then isolate the campsites that spawned those isochrones

camps_within_hour = gpd.read_file( "Camps_within_hour.geojson")

camps_hour_map = folium.Map(location=[-41.2769, 174.7731],zoom_start=5)

for row in camps_within_hour.iterrows():
    row_values = row[1]
    lat = row_values['geometry'].y
    long = row_values['geometry'].x
    name = row_values['name']
    folium.Marker(location=[lat,long],popup = name, icon=folium.Icon(color='red',icon='glass', prefix='fa')).add_to(camps_hour_map)


camps_hour_map
Out[9]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [10]:
#So it turns out there are 77 DOC campsites within one hours drive of a liquor store :)
#Happy holidays everyone

camps_within_hour.shape[0]
Out[10]:
77
In [ ]: